﻿Imports DTO
Imports System.Data.OleDb

Public Class ThamSoDAO

    Public Function LayBang() As DataTable
        Dim dt As New DataTable
        Dim cn As OleDbConnection = DataProvider.ConnectDB()
        Dim strSQL As String = "SELECT * FROM THAMSO"
        Dim da As OleDbDataAdapter = New OleDbDataAdapter(strSQL, cn)
        da.Fill(dt)
        cn.Close()
        Return dt
    End Function

    Public Function CapNhatBang(ByVal thsoDTO As ThamSoDTO) As Integer
        'Tạo kết nối
        Dim conn As OleDbConnection = DataProvider.ConnectDB()
        'Tạo câu truy vấn
        Dim strSQL As String = "UPDATE THAMSO SET TuoiToiThieu=" + thsoDTO.TuoiToiThieu.ToString() + " ,TuoiToiDa=" + thsoDTO.TuoiToiDa.ToString() + " ,SiSoToiDa1Lop=" + thsoDTO.SiSoToiDa.ToString() + " ,SoMonHoc=" + thsoDTO.SoMonHoc.ToString() + " ,DiemChuanDatMon=" + thsoDTO.DiemChuanDatMon.ToString()
        'Thực thi câu truy vấn
        Dim cmd As New OleDbCommand(strSQL, conn)
        Dim r As Integer = cmd.ExecuteNonQuery()
        'Đóng kết nối
        conn.Close()

        'Trả về kết quả
        If r = 1 Then
            Return 1
        Else
            Return 0
        End If
    End Function

End Class
